package cn.dengta.webapp.user.model;

import java.util.Date;

import cn.dengta.common.web.Client;
import cn.dengta.webapp.user.entity.ClientInfo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.StringUtil;
import me.codeplayer.util.X;

/**
 * 用于封装登录日志所需参数的实体类
 */
@Getter
@Setter
@Accessors(chain = true)
public class LoginLogEntry {

	/** 用户登录标识 */
	private String identity;
	/** 登录用户ID */
	private Long userId;
	/** 登录方式：0=通过密码；1=记住密码；2=短信验证码；3=微信授权登录；4=APP/API自动登录 */
	private ClientInfo.LoginWay loginWay;
	/** 登录时间 */
	private Date loginTime;
	/** 登录IP */
	private String loginIp;
	/** 请求来源客户端：0=PC端；1=WAP端；2=Android端；3=iOS端；4=后台或系统自动操作；5=其他；6=第三方 */
	private Client client;
	/** 客户端信息关联ID */
	private Long clientInfoId;

	public LoginLogEntry(String identity, Long userId, Client client, ClientInfo.LoginWay loginWay, Date loginTime, String loginIp, Long clientInfoId) {
		this.identity = StringUtil.toString(identity);
		this.userId = userId;
		this.client = client;
		this.loginWay = X.expectNotNull(loginWay, ClientInfo.LoginWay.BY_PASSWORD);
		this.loginTime = loginTime;
		this.loginIp = loginIp;
		this.clientInfoId = clientInfoId;
	}

}
